package xconfig

import (
	"context"
	"gitee.com/go-mid/infra/xobserver"
)

// Option ...
type Option func(ConfigCenter)

// ConfigerType ...
type ConfigerType string

type ConfigCenter interface {
	// RegisterObserver register observer return recall func to cancel observer
	RegisterObserver(ctx context.Context, namespace string, observer *xobserver.ConfigObserver) (recall func())
	// GetString get string value form specified namespace
	GetString(ctx context.Context, namespace, key string) (string, bool)
	// GetBool get bool value form specified namespace
	GetBool(ctx context.Context, namespace, key string) (bool, bool)
	// GetInt get int value form specified namespace
	GetInt(ctx context.Context, namespace, key string) (int, bool)
	// GetInt64 get int64 value form specified namespace
	GetInt64(ctx context.Context, namespace, key string) (int64, bool)
	// GetInt32 get int32 value form specified namespace
	GetInt32(ctx context.Context, namespace, key string) (int32, bool)
	// GetFloat64 get float64 value form specified namespace
	GetFloat64(ctx context.Context, namespace, key string) (float64, bool)
	// GetAllKeys get all keys form specified namespace
	GetAllKeys(ctx context.Context, namespace string) []string
	// Unmarshal unmarshal form specified namespace
	Unmarshal(ctx context.Context, namespace string, v interface{}) error
	// UnmarshalKey unmarshal key form specified namespace
	UnmarshalKey(ctx context.Context, namespace string, key string, v interface{}) error
}
type ConfigCenterInfo struct {
	//配置类型
	CfgType ConfigerType
	ConfigDriverInfo
}
type ConfigDriverInfo struct {
	//配置信息的根路径，
	CfgRootPath string
	//当前初始化配置中心的应用
	AppKey string
	//namespace
	NamespaceNames []string
}
